#coding=utf-8
'''
# @Name:default
# @author:mysouil
# @Description:默认的配置文件
# @DATE:2022/9/21 1:16
# @Modified By:
'''

# 默认配置
class DefaultConfig():
    # 数据库的配置变量
    HOSTNAME = '127.0.0.1'
    PORT = '3306'
    DATABASE = 'msb_shopping'
    USERNAME = 'mysouil'
    PASSWORD = '123456'
    DB_URI = 'mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE)
    
    SQLALCHEMY_DATABASE_URI = DB_URI
    # 不需要跟踪数据库数据的修改
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    
    # 日志的配置
    LOGGING_LEVEL = "INFO"    # DEBUG INFO
    LOGGING_FILE_DIR = 'logs/'
    LOGGING_FILE_MAX_BYTES = 300*1024*1024
    LOGGING_FILE_BACKUP = 10
    
    # 使用redis保存phone的数据(限流器采用redis保存数据)
    RATELIMIT_STORAGE_URL = 'redis://127.0.0.1:6379/6'
    # 限制策略 moving-window:移动窗口：时间窗口会自动变化
    RATELIMIT_STRATEGY = 'moving-window'
    
    # redis保存验证码的配置
    REDIS_URL = 'redis://127.0.0.1:6379/7'
    
    
# 开发环境的配置
class DevelopmentConfig(DefaultConfig):
    DEBUG = True
    # 打印sql
    SQLALCHEMY_ECHO = True

# 生产环境的配置信息
class ProductConfig(DefaultConfig):
    pass


# 把不同的环境配置和字符串串联起来
map_config = {
    'develop':DevelopmentConfig,
    'product':ProductConfig
}
